```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RabbitMQ消息确认机制 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-self;
            background-color: #f8fafc;
            color: #1e293b;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .prose {
            max-width: 65ch;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 5rem;
            line-height: 0.75;
            margin: 0.1em 0.1em 0.1em 0;
            color: #4f46e5;
            font-weight: 700;
        }
        .timeline-item:before {
            content: "";
            position: absolute;
            left: -1.5rem;
            top: 0;
            height: 100%;
            width: 2px;
            background-color: #cbd5e1;
        }
        .timeline-dot {
            position: absolute;
            left: -1.75rem;
            top: 0.25rem;
            width: 0.75rem;
            height: 0.75rem;
            border-radius: 9999px;
            background-color: #4f46e5;
        }
        .code-block {
            background-color: #1e293b;
            border-radius: 0.5rem;
            overflow: hidden;
        }
        .code-header {
            background-color: #0f172a;
            padding: 0.5rem 1rem;
            color: #94a3b8;
            font-family: monospace;
            font-size: 0.875rem;
        }
        .code-body {
            padding: 1rem;
            color: #e2e8f0;
            font-family: monospace;
            overflow-x: auto;
        }
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight:after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(79, 70, 229, 0.2);
            z-index: -1;
            transform: scaleX(1.05);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-24">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-4xl md:text-6xl font-bold mb-6 leading-tight">RabbitMQ消息确认机制</h1>
                <p class="text-xl md:text-2xl opacity-90 mb-8">保障分布式系统中消息的可靠传递与处理</p>
                <div class="flex justify-center space-x-4">
                    <a href="#publisher-confirms" class="px-6 py-3 bg-white text-indigo-600 font-semibold rounded-lg hover:bg-gray-100 transition duration-300">
                        <i class="fas fa-paper-plane mr-2"></i>发布者确认
                    </a>
                    <a href="#consumer-ack" class="px-6 py-3 bg-indigo-700 text-white font-semibold rounded-lg hover:bg-indigo-800 transition duration-300">
                        <i class="fas fa-check-circle mr-2"></i>消费者确认
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="max-w-4xl mx-auto mb-16">
            <div class="prose mx-auto">
                <p class="drop-cap">随着分布式系统和消息中间件的广泛应用，如何确保消息能够可靠地从生产者发送到消费者，并且避免因网络波动、系统故障等原因导致消息丢失，已经成为我们设计和使用消息队列时必须解决的问题。</p>
                <p>RabbitMQ作为一种流行的消息中间件，它提供了多种消息确认机制，能够有效地保证消息的可靠传递，并且支持不同场景下的容错与重试机制。</p>
            </div>
            <div class="mt-10 rounded-xl overflow-hidden shadow-lg">
                <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737684987758-24a2dfca-2e66-4c16-b848-3e7b62cd6fa4.png" alt="RabbitMQ架构图" class="w-full h-auto">
            </div>
        </section>

        <!-- Overview Section -->
        <section class="max-w-4xl mx-auto mb-16" id="overview">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-layer-group text-indigo-500 mr-3"></i>
                <span class="highlight">消息确认机制概述</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>RabbitMQ作为一种分布式消息队列系统，其核心功能之一就是保证消息在传递过程中不会丢失。而为了确保这一点，RabbitMQ提供了两种主要的消息确认机制：<strong>发布者确认（Publisher Confirms）</strong>和<strong>消费者确认（Consumer Acknowledgments）</strong>。</p>
                <p>这些机制的作用是通过确认机制让生产者和消费者双方在消息的发送和接收过程中都能够知道消息是否成功处理，从而保证系统的可靠性。</p>
            </div>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md border-l-4 border-indigo-500 hover:border-indigo-600 transition duration-300 card-hover">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-paper-plane text-indigo-500 mr-2"></i>发布者确认
                    </h3>
                    <p>生产者向RabbitMQ服务器发送消息后，RabbitMQ会给生产者一个确认信号，告知消息是否已经成功地写入到队列中。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md border-l-4 border-green-500 hover:border-green-600 transition duration-300 card-hover">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-green-500 mr-2"></i>消费者确认
                    </h3>
                    <p>消费者从RabbitMQ队列中成功消费并处理一条消息后，消费者需要通过ack信号告知RabbitMQ这条消息已经成功处理。</p>
                </div>
            </div>
            <div class="mt-10">
                <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737685086732-2e392a6a-133e-4195-8dc7-daab1b39f4ec.png" alt="消息确认机制示意图" class="w-full rounded-xl shadow-md">
            </div>
        </section>

        <!-- Why Needed Section -->
        <section class="max-w-4xl mx-auto mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-question-circle text-indigo-500 mr-3"></i>
                <span class="highlight">为什么需要消息确认？</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>消息确认机制主要用于解决以下问题：</p>
            </div>
            <div class="grid md:grid-cols-3 gap-4 mb-10">
                <div class="bg-white p-4 rounded-lg shadow-sm flex items-start">
                    <div class="bg-red-100 p-2 rounded-full mr-3">
                        <i class="fas fa-exclamation-triangle text-red-500"></i>
                    </div>
                    <div>
                        <h4 class="font-semibold">消息丢失</h4>
                        <p class="text-sm text-gray-600">网络故障、队列满等问题可能导致消息丢失</p>
                    </div>
                </div>
                <div class="bg-white p-4 rounded-lg shadow-sm flex items-start">
                    <div class="bg-yellow-100 p-2 rounded-full mr-3">
                        <i class="fas fa-redo text-yellow-500"></i>
                    </div>
                    <div>
                        <h4 class="font-semibold">消息重复处理</h4>
                        <p class="text-sm text-gray-600">网络问题可能导致消费者重复收到相同消息</p>
                    </div>
                </div>
                <div class="bg-white p-4 rounded-lg shadow-sm flex items-start">
                    <div class="bg-blue-100 p-2 rounded-full mr-3">
                        <i class="fas fa-sort-amount-down text-blue-500"></i>
                    </div>
                    <div>
                        <h4 class="font-semibold">消息顺序</h4>
                        <p class="text-sm text-gray-600">控制确认时机保证消息处理顺序性</p>
                    </div>
                </div>
            </div>
            <div class="bg-indigo-50 p-6 rounded-xl">
                <h3 class="text-xl font-bold mb-4 flex items-center">
                    <i class="fas fa-lightbulb text-indigo-500 mr-2"></i>
                    RabbitMQ消息确认的可靠性设计
                </h3>
                <ul class="space-y-2">
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                        <span><strong>持久化</strong>：通过消息确认机制，RabbitMQ能够确保持久化消息的安全性</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                        <span><strong>灵活性</strong>：可以根据应用需求选择不同的确认方式</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                        <span><strong>高可用</strong>：即使在系统崩溃后，已经确认的消息也不会丢失</span>
                    </li>
                </ul>
            </div>
        </section>

        <!-- Publisher Confirms Section -->
        <section class="max-w-4xl mx-auto mb-16" id="publisher-confirms">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-paper-plane text-indigo-500 mr-3"></i>
                <span class="highlight">发布者确认（Publisher Confirms）</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>发布者确认是RabbitMQ中一个重要的消息确认机制，旨在确保生产者发送的消息在RabbitMQ中被成功接收和路由到队列。它主要解决了消息丢失的问题，使得生产者能够知道其发送的消息是否已经成功被RabbitMQ接收并存储。</p>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-10">
                <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737685156938-dc21cdb0-3471-42c1-b876-f1c9790d2806.png" alt="发布者确认流程图" class="w-full">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-4">工作原理</h3>
                    <ol class="space-y-4 relative timeline">
                        <li class="timeline-item pl-8 relative">
                            <div class="timeline-dot"></div>
                            <h4 class="font-semibold">生产者发送消息</h4>
                            <p class="text-gray-600">生产者通过`channel.basicPublish()`方法发送消息到RabbitMQ的交换机</p>
                        </li>
                        <li class="timeline-item pl-8 relative">
                            <div class="timeline-dot"></div>
                            <h4 class="font-semibold">消息路由</h4>
                            <p class="text-gray-600">RabbitMQ接收到消息后，会将消息路由到相应的队列中</p>
                        </li>
                        <li class="timeline-item pl-8 relative">
                            <div class="timeline-dot"></div>
                            <h4 class="font-semibold">消息确认</h4>
                            <p class="text-gray-600">如果消息成功路由到队列并成功存储，RabbitMQ会发送确认回调</p>
                        </li>
                        <li class="timeline-item pl-8 relative">
                            <div class="timeline-dot"></div>
                            <h4 class="font-semibold">回调机制</h4>
                            <p class="text-gray-600">生产者注册确认监听器（ConfirmListener）接收RabbitMQ的确认结果</p>
                        </li>
                    </ol>
                </div>
            </div>

            <div class="mb-10">
                <h3 class="text-2xl font-bold mb-4 flex items-center">
                    <i class="fas fa-code text-indigo-500 mr-2"></i>
                    核心代码示例
                </h3>
                <div class="code-block">
                    <div class="code-header">
                        <span>Java - 发布者确认示例</span>
                    </div>
                    <div class="code-body">
                        <pre>channel.addConfirmListener(new ConfirmListener() {
    @Override
    public void handleAck(long deliveryTag, boolean multiple) throws IOException {
        System.out.println("Message Acknowledged: " + deliveryTag);
    }

    @Override
    public void handleNack(long deliveryTag, boolean multiple) throws IOException {
        System.out.println("Message Not Acknowledged: " + deliveryTag);
    }
});</pre>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-bolt text-indigo-500 mr-2"></i>异步确认
                    </h3>
                    <p>生产者使用异步方式接收确认，这样不会阻塞发送操作。生产者只需要在收到确认后再进行其他操作。</p>
                    <div class="mt-4 bg-indigo-50 p-4 rounded-lg">
                        <p class="font-semibold text-indigo-700">优势：</p>
                        <ul class="list-disc list-inside mt-2 text-sm">
                            <li>提高系统吞吐量</li>
                            <li>减少发送阻塞</li>
                            <li>适合高并发场景</li>
                        </ul>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-lock text-indigo-500 mr-2"></i>同步确认
                    </h3>
                    <p>在同步模式下，生产者会等待RabbitMQ返回确认结果，在确认消息被成功存储后，才能继续发送下一个消息。</p>
                    <div class="mt-4 bg-indigo-50 p-4 rounded-lg">
                        <p class="font-semibold text-indigo-700">优势：</p>
                        <ul class="list-disc list-inside mt-2 text-sm">
                            <li>更高的可靠性</li>
                            <li>保证消息顺序</li>
                            <li>适合关键业务场景</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Consumer Ack Section -->
        <section class="max-w-4xl mx-auto mb-16" id="consumer-ack">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-check-circle text-green-500 mr-3"></i>
                <span class="highlight">消费者确认（Consumer Acknowledgement）</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>消费者确认是RabbitMQ中的一个重要机制，确保消息在被消费者成功处理后能够被RabbitMQ从队列中移除。该机制可以防止消息丢失并确保消息在消费者处理失败时能够被重新消费。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-robot text-green-500 mr-2"></i>自动确认模式
                    </h3>
                    <p>这是RabbitMQ的默认模式，在该模式下，一旦消息从队列中交付给消费者，RabbitMQ就会认为该消息已经被成功消费并自动将其从队列中移除。</p>
                    <div class="mt-4 p-4 bg-green-50 rounded-lg">
                        <p class="font-semibold text-green-700">适用场景：</p>
                        <p class="text-sm mt-1">对消息丢失不敏感的应用</p>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-hand-paper text-green-500 mr-2"></i>手动确认模式
                    </h3>
                    <p>在手动确认模式下，消费者需要在处理完消息后，显式地调用`basicAck()`方法来告知RabbitMQ该消息已经被成功处理，并可以从队列中移除。</p>
                    <div class="mt-4 p-4 bg-green-50 rounded-lg">
                        <p class="font-semibold text-green-700">适用场景：</p>
                        <p class="text-sm mt-1">需要保证消息可靠处理的业务场景</p>
                    </div>
                </div>
            </div>

            <div class="mb-10">
                <h3 class="text-2xl font-bold mb-4 flex items-center">
                    <i class="fas fa-code text-green-500 mr-2"></i>
                    核心代码示例
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="code-block">
                        <div class="code-header">
                            <span>Java - 手动确认</span>
                        </div>
                        <div class="code-body">
                            <pre>// 手动确认消息
channel.basicAck(deliveryTag, false);  // false表示当前消息
channel.basicNack(deliveryTag, false, true);  // true表示重新投递</pre>
                        </div>
                    </div>
                    <div class="code-block">
                        <div class="code-header">
                            <span>Java - 消费者配置</span>
                        </div>
                        <div class="code-body">
                            <pre>channel.basicConsume(queueName, false, (consumerTag, delivery) -> {
    try {
        // 处理消息
        processMessage(delivery.getBody());
        // 手动确认
        channel.basicAck(deliveryTag, false);
    } catch (Exception e) {
        // 处理失败，拒绝消息
        channel.basicNack(deliveryTag, false, true);
    }
});</pre>
                        </div>
                    </div>
                </div>
            </div>

            <div class="bg-green-50 p-6 rounded-xl">
                <h3 class="text-xl font-bold mb-4 flex items-center">
                    <i class="fas fa-project-diagram text-green-500 mr-2"></i>
                    消费者确认流程
                </h3>
                <div class="mermaid">
                    sequenceDiagram
                        participant Producer
                        participant RabbitMQ
                        participant Consumer

                        Producer->>RabbitMQ: 发送消息
                        RabbitMQ->>Consumer: 投递消息
                        Consumer->>Consumer: 处理消息
                        alt 处理成功
                            Consumer->>RabbitMQ: 发送ACK确认
                            RabbitMQ->>RabbitMQ: 从队列删除消息
                        else 处理失败
                            Consumer->>RabbitMQ: 发送NACK拒绝
                            RabbitMQ->>RabbitMQ: 消息重新入队
                        end
                </div>
            </div>
        </section>

        <!-- Message Retry Section -->
        <section class="max-w-4xl mx-auto mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-redo text-purple-500 mr-3"></i>
                <span class="highlight">消息重试机制</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>消息重试机制在分布式消息队列系统中是至关重要的，它确保在消费者处理消息失败时，消息能够重新消费或进行适当的处理。RabbitMQ作为一个高效的消息中间件，提供了灵活的消息重试机制，能够保证在网络故障、消费者崩溃或其他异常情况下，消息不会丢失。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div>
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-skull-crossbones text-purple-500 mr-2"></i>
                        死信队列方案
                    </h3>
                    <div class="bg-white p-6 rounded-xl shadow-md">
                        <ol class="space-y-4">
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">1</span>
                                <span>配置死信队列和延迟队列</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">2</span>
                                <span>消息处理失败时发送到死信队列</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">3</span>
                                <span>设置TTL延迟时间后重新投递</span>
                            </li>
                        </ol>
                    </div>
                </div>
                <div>
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-list-ol text-purple-500 mr-2"></i>
                        重试次数方案
                    </h3>
                    <div class="bg-white p-6 rounded-xl shadow-md">
                        <ol class="space-y-4">
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">1</span>
                                <span>在消息header中添加重试次数计数</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">2</span>
                                <span>每次重试增加计数器</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-purple-100 text-purple-800 rounded-full w-6 h-6 flex items-center justify-center mr-3 flex-shrink-0">3</span>
                                <span>达到最大重试次数后转发到死信队列</span>
                            </li>
                        </ol>
                    </div>
                </div>
            </div>

            <div class="code-block">
                <div class="code-header">
                    <span>Java - 死信队列配置</span>
                </div>
                <div class="code-body">
                    <pre>// 创建原始队列
Map&lt;String, Object&gt; args = new HashMap&lt;&gt;();
args.put("x-dead-letter-exchange", ""); // 死信队列交换机
args.put("x-dead-letter-routing-key", "retryQueue"); // 死信队列的路由键

channel.queueDeclare("originalQueue", true, false, false, args);

// 创建死信队列（用于重试）
channel.queueDeclare("retryQueue", true, false, false, null);

// 创建延迟队列的配置（TTL）
Map&lt;String, Object&gt; retryArgs = new HashMap&lt;&gt;();
retryArgs.put("x-message-ttl", 10000);  // 消息在队列中最大存在时间（10秒）
retryArgs.put("x-dead-letter-exchange", ""); // 重新投递到原队列

channel.queueDeclare("retryQueue", true, false, false, retryArgs);</pre>
                </div>
            </div>
        </section>

        <!-- Performance Section -->
        <section class="max-w-4xl mx-auto mb-16">
            <h2 class="text-3xl font-bold mb-6 flex items-center">
                <i class="fas fa-tachometer-alt text-orange-500 mr-3"></i>
                <span class="highlight">消息确认的性能影响</span>
            </h2>
            <div class="prose mx-auto mb-8">
                <p>消息确认机制（Message Acknowledgment）是消息队列系统中至关重要的一部分，它确保消息的可靠传递和处理。然而，消息确认机制的使用虽然能够提升系统的可靠性，但也会对性能产生一定的影响。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-paper-plane text-orange-500 mr-2"></i>发布者确认性能影响
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-exchange-alt text-orange-500 mt-1 mr-2"></i>
                            <span>网络延迟增加</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-clock text-orange-500 mt-1 mr-2"></i>
                            <span>ACK确认消耗资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-database text-orange-500 mt-1 mr-2"></i>
                            <span>可能造成消息积压</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <h3 class="text-xl font-bold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-orange-500 mr-2"></i>消费者确认性能影响
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-hourglass-half text-orange-500 mt-1 mr-2"></i>
                            <span>确认等待时间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-stream text-orange-500 mt-1 mr-2"></i>
                            <span>消息积压风险</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-memory text-orange-500 mt-1 mr-2"></i>
                            <span>内存消耗增加</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-orange-50 p-6 rounded-xl">
                <h3 class="text-xl font-bold mb-4 flex items-center">
                    <i class="fas fa-lightbulb text-orange-500 mr-2"></i>
                    性能优化策略
                </h3>
                <div class="grid md:grid-cols-3 gap-4">
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-orange-500 mb-2">
                            <i class="fas fa-boxes text-xl"></i>
                        </div>
                        <h4 class="font-semibold">批量确认</h4>
                        <p class="text-sm text-gray-600 mt-1">将多个消息的确认合并为一次批量确认</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-orange-500 mb-2">
                            <i class="fas fa-sync-alt text-xl"></i>
                        </div>
                        <h4 class="font-semibold">异步处理</h4>
                        <p class="text-sm text-gray-600 mt-1">使用异步方式处理回调，避免阻塞主线程</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-orange-500 mb-2">
                            <i class="fas fa-sliders-h text-xl"></i>
                        </div>
                        <h4 class="font-semibold">预取值配置</h4>
                        <p class="text-sm text-gray-600 mt-1">合理设置basicQos限制未确认消息数量</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="max-w-4xl mx-auto mb-16">
            <div class="bg-indigo-600 text-white p-8 rounded-xl">
                <h2 class="text-2xl font-bold mb-4 flex items-center">
                    <i class="fas fa-star mr-3"></i>
                    <span>关键要点总结</span>
                </h2>
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <h3 class="text-xl font-semibold mb-3">发布者确认</h3>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>确保消息成功到达RabbitMQ</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>支持同步和异步确认模式</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>适合高可靠性要求的场景</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-xl font-semibold mb-3">消费者确认</h3>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>确保消息被成功处理</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>支持自动和手动确认模式</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle mt-1 mr-2 opacity-80"></i>
                                <span>配合死信队列实现重试机制</span>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="mt-6 bg-indigo-700 p-4 rounded-lg">
                    <h3 class="text-lg font-semibold mb-2 flex items-center">
                        <i class="fas fa-bullseye mr-2"></i>
                        最佳实践建议
                    </h3>
                    <ul class="space-y-1 text-sm">
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right mt-1 mr-2 opacity-80 text-xs"></i>
                            <span>根据业务场景选择合适的确认机制</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right mt-1 mr-2 opacity-80 text-xs"></i>
                            <span>对关键业务使用手动确认模式</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right mt-1 mr-2 opacity-80 text-xs"></i>
                            <span>合理设置预取值和批量确认优化性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chevron-right mt-1 mr-2 opacity-80 text-xs"></i>
                            <span>实现幂等性处理避免重复消息问题</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white">技术小馆</h3>
                    <p class="text-sm mt-1">专注于分布式系统与消息中间件技术</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition duration-300">
                        <i class="fas fa-external-link-alt mr-1"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-6 pt-6 text-center text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
    </script>
</body>
</html>
```